Release 10.1A: OpenEdge Development:
Web Services
Reusing an unchanged SOAP response header
This example shows how you might handle a SOAP header that you first encounter in the response message returned from the Web service, then use unchanged as the SOAP header for the next request. This is an example of the header returned from the Web service:
It contains one header entry,
AuthHeader, that contains a value used as an access key (AccessID). This type of header might be used when the Web service and client maintain a consistent context for each other between requests.This is the mainline of a procedure that invokes the Web service to reuse the response header:
This code:
- Defines several mainline variables, including a global handle to reference the reused SOAP header (
g_header).- Registers the request header (
ReqHandler) and response header (RespHandler) handlers after connecting to the Web service and instantiating theHeaderSoapport type procedure object.- Runs the
OpenAccessprocedure to invoke the Web service operation that returns theAccessIDvalue in the SOAP response header (see the "Response header handler for returning a header for reuse" section).- Runs the
HelloWorldprocedure to invoke the next Web service operation, passing back the SOAP response header to the Web service unchanged as the SOAP request header (see the "Request header handler for reusing a header" section).- Cleans up the global objects maintained in its context and disconnects from the Web service. Note that one of the objects it deletes is the original SOAP response header saved by the response header handler during execution of the
OpenAccessprocedure.Response header handler for returning a header for reuse
This is the SOAP response header handler (
RespHandler) that returns the header that is reused for passing around theAccessIDvalue:
This code:
- Receives the SOAP response header using the
hHeaderparameter.- Tests if the global header handle (
g_header) already references a valid object:
- If it does not reference an object, the handler must be running as part of the initial call to
OpenAccessand thus saves the input SOAP header object (hHeader) to the global context (g_header) for use by subsequent requests. From this moment forward, all requests to the Web service discard the header object input to the response handler as unnecessary.- If it does reference an object, the handle must already reference a SOAP response header returned in a prior request (the call to
OpenAccess) and has no need of a subsequent response header. It therefore deletes the unnecessary SOAP header object returned to the handler through thehHeaderparameter in order to prevent a memory leak accumulating in subsequent requests.Request header handler for reusing a header
This is the SOAP request header handler (
ReqHandler) that reuses the initial SOAP response header to pass theAccessIDvalue between the client and Web service:
This code:
- Sends the SOAP request header for the
HelloWorldrequest (and any request run after runningOpenAccess).- Tests if the global header handle (
g_header) references a valid object:
- If it does not reference an object, the request handler must be running as part of the initial call to
OpenAccessand sets the output parameters to ensure that no initial SOAP request header is sent.- If it does reference an object, the handler passes the global header object as output using the request header parameter (
hHeader) and ensures that the object is not deleted (saving it for use in any further request).
|
Copyright © 2005 Progress Software Corporation www.progress.com Voice: (781) 280-4000 Fax: (781) 280-4095 |